/*
 * Circle_queue.c
 *
 *  Created on: 2016-8-18
 *      Author: Liu Xiaopeng
 */
#include "sys.h"
//#include "font.h"

char queue_read(struct circle_queue *c_queue)
{
	if(c_queue->head == c_queue->tail)
	{
		return '$';
	}
	else
	{
		char rd_tem;
		rd_tem = c_queue->buffer[c_queue->tail];
		c_queue->tail = (c_queue->tail + 1) % Queue_Size;
		return rd_tem;
	}
}

void queue_store(char st_ch,struct circle_queue *c_queue)
{
	int st_tem;
	st_tem = (c_queue->head + 1) % Queue_Size;
	if(st_tem != c_queue->tail)
	{
		c_queue->buffer[c_queue->head] = st_ch;
		c_queue->head = st_tem;
	}
}

int available(struct circle_queue *c_queue)
{
	return (int)( c_queue->head - c_queue->tail + 6000 ) % Queue_Size;
}



